﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RBAC.api.Application.commond.RBAC;
using RBAC.Common.Domains;
using RBAC.Common.Dto;
using RBAC.Enum;
using System.Security;

namespace RBAC.api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {



        private readonly IMediator _mediatr;

        public ValuesController(IMediator mediatr)
        {
            _mediatr = mediatr;
        }


        /// <summary>
        /// 用户新增
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<Rulst> Useradd(UserCreateCommand cmd)
        {

            var result = await _mediatr.Send(cmd);

            return result;
        }

        /// <summary>
        /// 角色新增添加权限
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Rulst> Role(RoleCreateCommand request)
        {

            var result = await _mediatr.Send(request);

            return result;
        }





        /// <summary>
        /// 权限显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Rulst> Perssion(PermissionCreateCommond request)
        {

            var result  = await  _mediatr.Send(request);

            return result;
        }


        /// <summary>
        /// 权限添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]

        public async Task<Rulst> Handle(PermissionAddCommand request)
        {
            var list =await _mediatr.Send(request);

            return list;


        }
        /// <summary>
        /// 获取角色下拉框
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>

        [HttpPost]
        public async Task<Rulst> RoleSelect(RoleSelectCommond request)
        {

            var result =  await _mediatr.Send(request);
            return result;



        }

        /// <summary>
        /// 权限添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Rulst> PerssionAdd(PermissionAddCommand request)
        {
            var list = await _mediatr.Send(request);


            return list;


        }
        /// <summary>
        /// 角色权限显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>

        [HttpPost]
        public async Task<Rulst> RolePerssion(UserHtmlCommond request)
        {

            var result = await _mediatr.Send(request);

            return result;
        }


        /// <summary>
        /// 用户角色列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpPost]
        public async Task<Rulst> UserRole(USerRoleHtmlCommand request, CancellationToken cancellationToken)
        {

            var query =await _mediatr.Send(request);
            return query;


        }




        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Rulst> UserLogin(UserLoginCommond request, CancellationToken cancellationToken)
        {


            var query =await _mediatr.Send(request);

            return query;



        }

        /// <summary>
        /// 用户权限获取
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Rulst> UserLoginPerssion(UserPerssionCommond request, CancellationToken cancellationToken)
        {

            var query = await _mediatr.Send(request);
            return query;



        }


    }
}
